package by.siarhei.java.tij.reusing.exercises.ex05;

/**
 * @author Siarhei Shchahratsou <s.siarhei@gmail.com>
 * @since 09.03.14
 */
public class C extends A {
    private final B b;

    void method() {
        System.out.println("C.method()");
    }

    void caller() {
        System.out.print("C.this.method() - ");
        this.method();

        System.out.print("C.super.method() - ");
        super.method();

        System.out.print("C.method() - ");
        method();
    }

    public static void main(String[] args) {
        new C().caller();
        new C().baseCaller();
        new A('a').baseCaller();

        A a = new C();
        a.baseCaller();
    }

    public C() {
        super('a');
        b = new B('b');
    }
}

class A {
    A(char a) {
        System.out.println("A: " + a);
    }

    void method() {
        System.out.println("A.method()");
    }

    void baseCaller() {
        System.out.print("A.this.method() - ");
        this.method();

        System.out.print("A.method() - ");
        method();
    }
}

class B {
    B(char b) {
        System.out.println("B: " + b);
    }
}
